<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: Jammit::CommandLine
  
    &mdash; Jammit
  
</title>

  <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />

  <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  hasFrames = window.top.frames.main ? true : false;
  relpath = '../';
  framesUrl = "../frames.html#!Jammit/CommandLine.html";
</script>


  <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>


  </head>
  <body>
    <div id="header">
      <div id="menu">
  
    <a href="../_index.html">Index (C)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../Jammit.html" title="Jammit (module)">Jammit</a></span></span>
     &raquo; 
    <span class="title">CommandLine</span>
  

  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../class_list.html">
      Class List
    </a>
  
    <a class="full_list_link" id="method_list_link"
        href="../method_list.html">
      Method List
    </a>
  
    <a class="full_list_link" id="file_list_link"
        href="../file_list.html">
      File List
    </a>
  
</div>
      <div class="clear"></div>
    </div>

    <iframe id="search_frame"></iframe>

    <div id="content"><h1>Class: Jammit::CommandLine
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Jammit::CommandLine</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">lib/jammit/command_line.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>The <code>CommandLine</code> is able to compress, pre-package, and pre-gzip all the
assets specified in the configuration file, in order to avoid an initial
round of slow requests after a fresh deployment.</p>

  </div>
</div>
<div class="tags">
  

</div>
  <h2>Constant Summary</h2>
  
    <dl class="constants">
      
        <dt id="BANNER-constant" class="">BANNER =
          
        </dt>
        <dd><pre class="code"><span class='heredoc_beg'>&lt;&lt;-EOS</span>
<span class='tstring_content'>
Usage: jammit OPTIONS

Run jammit inside a Rails application to compresses all JS, CSS,
and JST according to config/assets.yml, saving the packaged
files and corresponding gzipped versions.

If you&#39;re using &quot;embed_assets&quot;, and you wish to precompile the
MHTML stylesheet variants, you must specify the &quot;base-url&quot;.

Options:
</span><span class='heredoc_end'>EOS</span></pre></dd>
      
    </dl>
  







  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="private ">
  <span class="summary_signature">
    
      <a href="#ensure_configuration_file-instance_method" title="#ensure_configuration_file (instance method)">- (Object) <strong>ensure_configuration_file</strong> </a>
    

    
  </span>
  
  
  
  <span class="note title private">private</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Make sure that we have a readable configuration file.</p></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">- (CommandLine) <strong>initialize</strong> </a>
    

    
  </span>
  
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>The <code>Jammit::CommandLine</code> runs from the contents of <code>ARGV</code>.</p></div></span>
  
</li>

      
        <li class="private ">
  <span class="summary_signature">
    
      <a href="#parse_options-instance_method" title="#parse_options (instance method)">- (Object) <strong>parse_options</strong> </a>
    

    
  </span>
  
  
  
  <span class="note title private">private</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Uses <code>OptionParser</code> to grab the options: <strong>&#8212;output</strong>, <strong>&#8212;config</strong>, and <strong>&#8212;base-url</strong>&#8230;</p></div></span>
  
</li>

      
    </ul>
  

<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <h3 class="signature first" id="initialize-instance_method">
  
    - (<tt><span class='object_link'><a href="" title="Jammit::CommandLine (class)">CommandLine</a></span></tt>) <strong>initialize</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>The <code>Jammit::CommandLine</code> runs from the contents of <code>ARGV</code>.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


26
27
28
29
30</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/command_line.rb', line 26</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
  <span class='id identifier rubyid_parse_options'>parse_options</span>
  <span class='id identifier rubyid_ensure_configuration_file'>ensure_configuration_file</span>
  <span class='const'>Jammit</span><span class='period'>.</span><span class='id identifier rubyid_package!'>package!</span><span class='lparen'>(</span><span class='ivar'>@options</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
  
</div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="ensure_configuration_file-instance_method">
  
    - (<tt>Object</tt>) <strong>ensure_configuration_file</strong>  <span class="extras">(private)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Make sure that we have a readable configuration file. The <code>jammit</code>
command can&#8217;t run without one.</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


37
38
39
40
41
42</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/command_line.rb', line 37</span>

<span class='kw'>def</span> <span class='id identifier rubyid_ensure_configuration_file'>ensure_configuration_file</span>
  <span class='id identifier rubyid_config'>config</span> <span class='op'>=</span> <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:config_path</span><span class='rbracket'>]</span>
  <span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_exists?'>exists?</span><span class='lparen'>(</span><span class='id identifier rubyid_config'>config</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_readable?'>readable?</span><span class='lparen'>(</span><span class='id identifier rubyid_config'>config</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Could not find the asset configuration file \&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_config'>config</span><span class='embexpr_end'>}</span><span class='tstring_content'>\&quot;</span><span class='tstring_end'>&quot;</span></span>
  <span class='id identifier rubyid_exit'>exit</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="parse_options-instance_method">
  
    - (<tt>Object</tt>) <strong>parse_options</strong>  <span class="extras">(private)</span>
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Uses <code>OptionParser</code> to grab the options: <strong>&#8212;output</strong>, <strong>&#8212;config</strong>, and
<strong>&#8212;base-url</strong>&#8230;</p>

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/jammit/command_line.rb', line 46</span>

<span class='kw'>def</span> <span class='id identifier rubyid_parse_options'>parse_options</span>
  <span class='ivar'>@options</span> <span class='op'>=</span> <span class='lbrace'>{</span>
    <span class='symbol'>:config_path</span>    <span class='op'>=&gt;</span> <span class='const'>Jammit</span><span class='op'>::</span><span class='const'>DEFAULT_CONFIG_PATH</span><span class='comma'>,</span>
    <span class='symbol'>:output_folder</span>  <span class='op'>=&gt;</span> <span class='kw'>nil</span><span class='comma'>,</span>
    <span class='symbol'>:base_url</span>       <span class='op'>=&gt;</span> <span class='kw'>nil</span><span class='comma'>,</span>
    <span class='symbol'>:force</span>          <span class='op'>=&gt;</span> <span class='kw'>false</span>
  <span class='rbrace'>}</span>
  <span class='ivar'>@option_parser</span> <span class='op'>=</span> <span class='const'>OptionParser</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_opts'>opts</span><span class='op'>|</span>
    <span class='id identifier rubyid_opts'>opts</span><span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>-o</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>--output PATH</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>output folder for packages (default: &quot;public/assets&quot;)</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_output_folder'>output_folder</span><span class='op'>|</span>
      <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:output_folder</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_output_folder'>output_folder</span>
    <span class='kw'>end</span>
    <span class='id identifier rubyid_opts'>opts</span><span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>-c</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>--config PATH</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>path to assets.yml (default: &quot;config/assets.yml&quot;)</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_config_path'>config_path</span><span class='op'>|</span>
      <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:config_path</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_config_path'>config_path</span>
    <span class='kw'>end</span>
    <span class='id identifier rubyid_opts'>opts</span><span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>-u</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>--base-url URL</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>base URL for MHTML (ex: &quot;http://example.com&quot;)</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_base_url'>base_url</span><span class='op'>|</span>
      <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:base_url</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_base_url'>base_url</span>
    <span class='kw'>end</span>
    <span class='id identifier rubyid_opts'>opts</span><span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>-f</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>--force</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>force a rebuild of all assets</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_force'>force</span><span class='op'>|</span>
      <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:force</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_force'>force</span>
    <span class='kw'>end</span>
    <span class='id identifier rubyid_opts'>opts</span><span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>-p</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>--packages LIST</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>list of packages to build (ex: &quot;core,ui&quot;, default: all)</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_package_names'>package_names</span><span class='op'>|</span>
      <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:package_names</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_package_names'>package_names</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>,\s*</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='rbrace'>}</span>
    <span class='kw'>end</span>
    <span class='id identifier rubyid_opts'>opts</span><span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>-P</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>--public-root PATH</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>path to public assets (default: &quot;public&quot;)</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_public_root'>public_root</span><span class='op'>|</span>
      <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Option for PUBLIC_ROOT</span><span class='tstring_end'>&quot;</span></span>
      <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:public_root</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_public_root'>public_root</span>
    <span class='kw'>end</span>
    <span class='id identifier rubyid_opts'>opts</span><span class='period'>.</span><span class='id identifier rubyid_on_tail'>on_tail</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>-v</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>--version</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>display Jammit version</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
      <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Jammit version </span><span class='embexpr_beg'>#{</span><span class='const'>Jammit</span><span class='op'>::</span><span class='const'>VERSION</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
      <span class='id identifier rubyid_exit'>exit</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
  <span class='ivar'>@option_parser</span><span class='period'>.</span><span class='id identifier rubyid_banner'>banner</span> <span class='op'>=</span> <span class='const'>BANNER</span>
  <span class='ivar'>@option_parser</span><span class='period'>.</span><span class='id identifier rubyid_parse!'>parse!</span><span class='lparen'>(</span><span class='const'>ARGV</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

    <div id="footer">
  Generated on Wed Oct 28 12:19:04 2015 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.7.6 (ruby-2.1.3).
</div>

  </body>
</html>